﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:Imagin.Controls.Common"
    xmlns:Common="http://imagin.tech/imagin/common">
    <Common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    <Common:StringToVisibilityConverter x:Key="StringToVisibilityConverter"/>

    <Style x:Key="{x:Type local:FileBox}" TargetType="{x:Type local:FileBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FileBox}">
                    <Border
                        BorderThickness="{TemplateBinding BorderThickness}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        Background="{TemplateBinding Background}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="PART_Column1" Width="*"/>
                                <ColumnDefinition x:Name="PART_Column2" Width="Auto"/>
                                <ColumnDefinition x:Name="PART_Column3" Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid x:Name="PART_Text">
                                <TextBlock 
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    Margin="{TemplateBinding Padding}"
                                    Style="{TemplateBinding PlaceholderStyle}"
                                    Text="{TemplateBinding Placeholder}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Visibility="{TemplateBinding Text, Converter={StaticResource StringToVisibilityConverter}, ConverterParameter=Inverted}"/>
                                <ScrollViewer 
                                    x:Name="PART_ContentHost" 
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    Margin="{TemplateBinding Padding}"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Grid>
                            <local:MaskedImage 
                                Grid.Column="1" 
                                x:Name="PART_Indicator"
                                ImageColor="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"
                                Margin="5,0,0,0"
                                Source="pack://application:,,,/Imagin.Controls.Common;component/Images/CheckmarkRound.png"
                                Visibility="{Binding IsValid, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <local:MaskedButton 
                                Grid.Column="2" 
                                x:Name="PART_Button"
                                Focusable="False"
                                ImageColor="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"
                                IsEnabled="{TemplateBinding CanBrowse}"
                                Padding="7,0" 
                                Source="pack://application:,,,/Imagin.Controls.Common;component/Images/Folder.png"
                                ToolTip="{TemplateBinding ButtonToolTip}"
                                Visibility="{TemplateBinding ButtonVisibility}"/>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ButtonPosition" Value="Left">
                            <Setter TargetName="PART_Column1" Property="Width" Value="Auto"/>
                            <Setter TargetName="PART_Column2" Property="Width" Value="*"/>
                            <Setter TargetName="PART_Column3" Property="Width" Value="Auto"/>

                            <Setter TargetName="PART_Button" Property="Padding" Value="7,0,0,0"/>

                            <Setter TargetName="PART_Text" Property="Grid.Column" Value="1"/>
                            <Setter TargetName="PART_Indicator" Property="Grid.Column" Value="2"/>
                            <Setter TargetName="PART_Indicator" Property="Margin" Value="5,0"/>
                            <Setter TargetName="PART_Button" Property="Grid.Column" Value="0"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>